<script type="text/javascript">
    $(document).ready(function() {
        $("#activity_checkAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<legend>
    <h4>
        <?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEvent@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('会员卡管理', array(
            'cooker' => 'BAMemberCard@showUserCardHome'
        ));
        ?>\申请会员卡
        <?php
        /*
          $cardTypeAlias = $cardType->getValue();
          echo $cardTypeAlias;
         * 
         */
        ?>
    </h4>
</legend>
<?php if (!isset($applyView) || $applyView == NULL) { ?>
    <div class="well">
        <h5 class="text-error">已经申请了所有的卡，谢谢！您可以通过以下链接查看您的卡：</h5>
        <?php
        echo $control->getAjaxLink('我的会员卡', array(
            'cooker' => 'BAMemberCard@showUserCardList',
            'htmlOptions' => array('class' => 'btn btn-warning')
        ));
        ?>
    </div>
    <?php
    return;
}
?>
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th><input type="checkbox" name="activity_checkAll" id="activity_checkAll"></th>
                <th>卡类型</th>
                <th>批准方式</th>
                <th>操作</th>
            </tr> 
        </thead>
        <tbody>
            <?php
            $memberCardCooker = new BAMemberCardCooker();
            $permitCooker = new BAPermitCooker();
            foreach ($applyView as $id => $lastChangeTime) {
                $permit = $permitCooker->getPermit($id);
                $typeId = $permit->getItem('cardTypeId')->getValue();
                $cardType = $memberCardCooker->getCardType($typeId);
                $cardTypeAlias = $cardType->getValue();
                $permitName = $permit->getItem('permit')->getValue();
                $permitAlias = BAMemberCardCooker::getPermitAlias($permitName);
                if ($permitName == BAMemberCardCooker::Permit_Allow_AddCard) {
                    $aLink = $control->getAjaxLink('领取', array(
                        'cooker' => 'BAMemberCard@showUserAddCard',
                        'cardTypeId' => $typeId,
                        'permitId' => $id
                    ));
                }
                if ($permitName == BAMemberCardCooker::Permit_Allow_Approve) {
                    $aLink = $control->getAjaxLink('申请', array(
                        'cooker' => 'BAMemberCard@showUserApplyCard',
                        'cardTypeId' => $typeId,
                        'permitId' => $id
                    ));
                }
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="subBox[]" value="<?php echo $id; ?>"> 
                        </label></td>
                    <td> <?php echo $cardTypeAlias; ?> </td>
                    <td><?php echo $permitAlias; ?></td>
                    <td>
                        <div class="row-fluid">
                            <?php
                            if (isset($aLink) && $aLink != NULL)
                                echo $aLink;
                            ?>
                        </div>                   
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
